var RenYuan = new Vue({

    el : '#kaohelist',
    data :{
        bshqk:'jj',
        deptid:'',
        jiashuname:'',
        shifoubangding:'',
        shenfenzhenghao:'',
        qiyename:'',
        renyuan : {},
        chahe:{},
        jingshang:{},
        jingshanglist:[],
        jiashuList:[],
        chaheList : [],
        renyuanleibielist:[],
        danweinamelist:[],


        editFlag : 0,					// 0:新增，1：修改
        show : false,					// 显示列表是否有数据
        jingshangqingkuang: false,

        pageIndex : 1,
        pageSize :6,
        pageCount : 0,
        recordCount : 0,
        inputPageIndexValue : "",


    },
    created : function() {

        this.findVaild(0);
        this.selectDepNameByValid();
        this.initDict();


    },
    methods : {

        // 绑定字典表
        initDict : function() {
            var _this = this;

            // 人员类别
            $.post("../dict_renyuanleibie/find_valid", {
                rdm : Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == '1') {
                        var data = ppData.resultContent;
                        _this.renyuanleibielist = data;
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        selectDepNameByValid : function() {
            var _this = this;

            // 单位名称
            $.post("../dept/findcengji_by_deptid", {
                deptid: 0,
                rdm : Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == '1') {
                        var data = ppData.resultContent;
                        _this.danweinamelist = data;
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        findVaild: function(ppFlag){
            var _this = this;
            if (ppFlag==1){
                _this.pageIndex=1;
            }
            layer.open({type:3});
            $.post("../jiashu/find_jingshangchaheduibi_by_deptid_and_name",{
                deptid : _this.deptid,
                jiashuname: _this.jiashuname,
                startindex : _this.pageIndex,
                pagesize : _this.pageSize,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        var data=ppData.resultContent;

                        if(data.JiashuList.length > 0){
                            _this.show = true;
                            _this.jiashuList=data.JiashuList;

                            var PageInfo = data.PageInfo;
                            _this.pageIndex = PageInfo.pageIndex;
                            _this.recordCount = PageInfo.recordCount;
                            _this.pageCount = PageInfo.pageCount;

                        }else {
                            _this.show = false;
                        }

                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },

        findbshqk: function(){
            var _this = this;
            $(".bsh").hide();
            $("#"+_this.bshqk).show();

            layer.open({type:3});
            $.post("../jiashu/find_jingshangchaheduibi_by_deptid_and_name",{
                deptid : _this.deptid,
                jiashuname: _this.jiashuname,
                startindex : _this.pageIndex,
                pagesize : _this.pageSize,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        var data=ppData.resultContent;

                        if(data.JiashuList.length > 0){
                            _this.show = true;
                            _this.jiashuList=data.JiashuList;

                            var PageInfo = data.PageInfo;
                            _this.pageIndex = PageInfo.pageIndex;
                            _this.recordCount = PageInfo.recordCount;
                            _this.pageCount = PageInfo.pageCount;

                        }else {
                            _this.show = false;
                        }

                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },

        ShowJingshang:function (){
            var _this = this;
            _this.jingshanglist="";
            _this.chaheList="";
            $("#kaoheModal").modal();
            _this.findbshqk();
           /* $("#myModalLabel").html(ppJiashu.truename+"的"+ppJiashu.guanxitext+ppJiashu.name+"的个人填报信息与查核反馈信息比对");
            _this.findJingshangByJiashuId(ppJiashu.jiashuid);
            _this.findChaheByJiashuId(ppJiashu.jiashuid);*/
        },

        findJingshangByJiashuId: function(ppJiashuId){
            var _this = this;
            layer.open({type:3});
            $.post("../jingshangqingkuang/find_vaild_by_jiashuid",{
                jiashuid : ppJiashuId,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        var data=ppData.resultContent;

                        if(data.length > 0){
                            _this.jingshanglist=data;
                        }

                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },

        findChaheByJiashuId: function(ppJiashuId){
            var _this = this;
            layer.open({type:3});
            $.post("../chaheqingkuang/find_by_jiashuid",{
                jiashuid : ppJiashuId,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        var data=ppData.resultContent;

                        if(data.length > 0){
                            _this.chaheList=data;
                        }

                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },

        bangdingxianshi:function (ppId) {
            $(".duibi").removeClass("bangdingxianshi");
            $("#js"+ppId).addClass("bangdingxianshi");
            $("#ch"+ppId).addClass("bangdingxianshi");
        },
        close:function (){
            $(".duibi").removeClass("bangdingxianshi");
        },

        /*findJingshang: function(){
            var _this = this;
            layer.open({type:3});
            $.post("../jingshangqingkuang/find_by_shenfenzheng_and_qiyename",{
                shenfenzhenghao : _this.shenfenzhenghao,
                qiyename: _this.qiyename,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        var data=ppData.resultContent;

                        if(data.length > 0){
                            _this.jingshanglist=data;
                        }

                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },

        bangding: function(ppChaheId,ppJingshangId){
            var _this = this;
            layer.open({type:3});
            $.post("../chaheqingkuang/bangding",{
                chaheid : ppChaheId,
                jingshangid: ppJingshangId,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        _this.findVaild();
                        layer.alert("绑定成功！");
                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },*/


        //跳到首页
        SetPageIndex : function(){
            this.pageIndex = 1;
        },
        SetPageEnd : function(){
            this.pageIndex = this.pageCount;
        },
        //上一页
        SetPageIndexPrePage : function(){
            var PrePage = ((this.pageIndex -1) <= 0) ? 1 : (this.pageIndex -1);
            this.pageIndex = PrePage;
        },
        //下一页
        SetPageIndexNextPage : function(){
            var NextPage = ((this.pageIndex +1) >= this.pageCount) ? this.pageCount : (this.pageIndex +1);
            this.pageIndex = NextPage;
        },
        //跳转界面
        JumpPage : function(){
            if(this.inputPageIndexValue <= 1){
                this.inputPageIndexValue = 1;
            }else if(this.inputPageIndexValue >= this.pageCount){
                this.inputPageIndexValue = this.pageCount;
            }
            this.pageIndex = this.inputPageIndexValue;
            this.inputPageIndexValue = '';
        },




    },
    watch :{
        //监控分页情况，刷新列表
        pageIndex : function(){

            this.findVaild(0);
        }
    }

});
